﻿using Gecko.Entities;
using NHibernate;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NHibernate.Linq;

namespace Gecko.Respositories
{
    public class HistoryRepository : RepositoryBase<WaterLeakHistory>
    {
        public HistoryRepository(ISession session)
            : base(session)
        {

        }

        public IList<WaterLeakHistory> GetHistoryByWaterLeakId(int waterLeakId)
        {
            var waterLeak = Session.Query<WaterLeak>().FirstOrDefault(p => p.Id == waterLeakId);
            if (waterLeak != null)
            {
                return waterLeak.Histories;
            }
            else
            {
                throw new Exception("Not Found WaterLeak");
            }
        }
    }
}